﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Reporting.WebForms;
using Ewts.Code;

namespace Ewts.RDLC
{
    public partial class DisassembleRDLC : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                int outStorID = 0;
                
                if (Request["outStorID"] != null && Request["outStorID"].ToString().Trim() != "")
                {
                    outStorID = int.Parse(Request["outStorID"].ToString().Trim());
                    //GetReportMultipleDataSourceFile
                }

                BindData(outStorID);
            }
        }

        protected void BindData(int outStorID)
        {
            List<ReportParameter> parameterList = new List<ReportParameter>();
            DataSet barCodeDS = new DataLib.BLL.BarCode().GetList("outstrorageid = '" + outStorID + "'");
            DataLib.Model.OutStorage outStorM = new DataLib.BLL.OutStorage().GetModel(outStorID);

            //参数数据
            if (outStorM != null)
            {
                parameterList.Add(new ReportParameter("InDepart", outStorM.inDepart));
                parameterList.Add(new ReportParameter("OutDepart", outStorM.OutDepart));
                parameterList.Add(new ReportParameter("Date", ((DateTime)outStorM.outStorageDate).ToLongDateString().ToString()));
            }

            //为列表绑定数据
            ReportDataSource rds = new ReportDataSource("DataSet1", barCodeDS.Tables[0]);
            ReportViewer1.LocalReport.DataSources.Clear();
            ReportViewer1.LocalReport.DataSources.Add(rds);
            new RDLCPrinter().FillRow(barCodeDS.Tables[0], 3,25, 25);//为列表添加空行
            ReportViewer1.LocalReport.SetParameters(parameterList);
            ReportViewer1.LocalReport.Refresh();
        }
    }
}